.global _start
.org 0x0
_start:
	jal x1,in

.org 0x40
	li x1,0x20000004
	li x2,0x00000000
	lw x2,0x0(x1)
	li x3,0xffffffff
	xor x2,x2,x3
	sw x2,0x0(x1)
	
	li x1,0x50000000
	li x2,0x00000003
	sw x2,0x0(x1)
	
	li x1,0x00
	csrrw x2,mip,x1
	li x1,0x08
	csrrw x2,mstatus,x1

	mret

.org 0x100
in:
	#亮灯
	li x1,0x20000008
	li x2,0xffffffff
	sw x2,0x0(x1)
	
	li x1,0x2000000c
	li x2,0x00000000
	sw x2,0x0(x1)
	
	li x1,0x20000004
	li x2,0x47404106
	sw x2,0x0(x1)
	
	#设置中断
	li x3,0x40000040
	csrrw x4,mtvec,x3
	li x1,0x80
	csrrw x2,mie,x1
	li x1,0x08
	csrrw x2,mstatus,x1
	
	#设置定时器
	li x1,0x50000008
	li x2,0x00500000
	sw x2,0x0(x1)
	
	li x1,0x50000000
	li x2,0x00000003
	sw x2,0x0(x1)
stop:	
	j stop

